﻿<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style media=print>
.Noprint {
	display: none;
}

.PageNext {
	page-break-after: always;
}
</style>
<script type="text/javascript" language="javascript">

/* 重新加载当前页（后台重新查询记录数量并转到当前页） */
function reloadCurrentPage(){
	document.getElementById("isReload").value = "1";
	document.forms[0].submit();
}

/* 重新加载列表（后台重新查询记录数量并转到第一页） */
function reloadPage(){
	document.getElementById("isReload").value = "1";
	document.getElementById("pageIndex").value = "1";
	document.forms[0].submit();
}

function goPointPage(){
	if(checkGoPageIndex()){
		goToPageIndex(document.getElementById("goPageIndex").value);
	}
}
function goFirstPage(){
	goToPageIndex(1);
}
function goLastPage(){
	goToPageIndex(document.getElementById("pageCount").value);
}
function goPreviousPage(){
	goToPageIndex(parseInt(document.getElementById("pageIndex").value)-1);
}
function goNextPage(){
	goToPageIndex(parseInt(document.getElementById("pageIndex").value)+1);
}

function goToPageIndex(pageIndex){
	//document.getElementById("pageIndex").value = pageIndex;
	document.forms[0].action = document.forms[0].action + "&page.pageIndex=" + pageIndex;
	document.forms[0].submit();
}

function checkGoPageIndex() {
	var reg = /^[0-9]\d*$/;
	if(isNaN(document.getElementById("goPageIndex").value)) {
		alert('页码必须是数字！');
		return false;
	}else if(parseInt(document.getElementById("goPageIndex").value)<=0){
		alert('页码必须大于0');
		return false;
	}else if(!reg.test(document.getElementById("goPageIndex").value)){ 
		alert("请输入整数!");   
		return false;
	}else if(parseInt(document.getElementById("goPageIndex").value) > parseInt(document.getElementById("pageCount").value)){
		alert('页码不能超过最大页数');
		return false;
	}
	return true;
}
</script>
<table border="0" cellspacing="0" cellpadding="0" class="listToolbar">
	<tr>
		<td class="listInfo">共${page.rowCount}条,<input id="goPageIndex" name="goPageIndex" type="text" size="1" class="text" maxlength="5" 
			value="${page.pageIndex}" onkeypress="if(event.keyCode==13){goPointPage();}" />/${page.pageCount}页
		</td>
		<td>
			<input type="button" onclick="goPointPage()" value="" class="goto" />
			<input type="hidden" id="pageCount" value="${page.pageCount}">
			<input type="hidden" id="pageIndex" name="pageIndex" value="${page.pageIndex}">
			<input type="hidden" id="rowCount" name="page.rowCount" value="${page.rowCount}">
			<input type="hidden" id="isReload" name="isReload" />
		</td>
		<c:choose>
			<c:when test="${page.pageCount!=0}">
				<td>
					<c:choose>
						<c:when test="${page.pageIndex!=0&&page.pageIndex!=1}">
							<input type="button" onclick="goFirstPage()" class="firstPage" value="" />
						</c:when>
						<c:otherwise>
							<input type="button" class="firstPageOff" value="" />
						</c:otherwise>
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${page.pageIndex!=0&&page.pageIndex!=1}">
							<input type="button" onclick="goPreviousPage()" value="" class="prevPage" />
						</c:when> 
						<c:otherwise> 
							<input type="button" value="" class="prevPageOff" />
						</c:otherwise>
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${page.pageIndex!=page.pageCount}">
							<input type="button" onclick="goNextPage()" value="" class="nextPage" />
						</c:when> 
						<c:otherwise>
							<input type="button" value="" class="nextPageOff" />
						</c:otherwise>
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${page.pageIndex!=page.pageCount}">
							<input type="button" onclick="goLastPage()" value="" class="lastPage" />
						</c:when>
						<c:otherwise>
							<input type="button" value="" class="lastPageOff" />
						</c:otherwise>
					</c:choose>
				</td>
			</c:when>
			<c:otherwise>
				<td>
					<input type="button" class="firstPageOff" value="" />
				</td>
				<td>
					<input type="button" class="prevPageOff" value="" />
				</td>
				<td>
					<input type="button" class="nextPageOff" value="" />
				</td>
				<td>
					<input type="button" class="lastPageOff" value="" />
				</td>
			</c:otherwise>
		</c:choose>
	</tr>
</table>